package com.qk.mapper;

import com.qk.entity.Course;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * ClassName: CourseMapper
 * Package: com.qk.mapper
 * Description:
 *
 * @Author zt
 * @Create 2025/7/28 23:44
 * @Version 1.0
 */
@Mapper
public interface CourseMapper {
    List<Course> selectByCondition(String name, Integer subject, Integer target);

    @Select("insert into course(subject, name, target, price, description, create_time, update_time) " +
            "values(#{subject}, #{name}, #{target}, #{price}, #{description}, #{createTime}, #{updateTime})")
    void add(Course course);

    @Delete("delete from course where id = #{id}")
    void delete(Integer id);

    @Select("select id, subject, name, price, target, description, create_time, update_time from course where id = #{id}")
    Course getById(Integer id);

    void update(Course course);

    //查询所有课程
    @Select("select id, subject, name, price, target, description, create_time, update_time from course")
    List<Course> list();

    @Select("select id, subject, name, price, target, description, create_time, update_time from course where subject = #{subject}")
    List<Course> listBySubject(Integer subject);
}
